﻿using TaoSH.AppCode;
using TaoSH.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TaoSH.View
{
    public partial class SYLB : FormUControl
    {




        #region//添加页面

        public override void initAddForm(string strFormCode)
        {

        }




        /// <summary>
        /// 送审表单
        /// </summary>
        /// <param name="FormID">表单号</param>
        /// <param name="intProcessInstanceID">流程号</param>
        /// <returns></returns>
        public override bool SaveForm(int intFormID, string strActionType)
        {
            PT_Index_Type MODEL = new PT_Index_Type();
            MODEL = new PT_Index_TypeB().GetEntity(d => d.ID == intFormID);
            MODEL.TypeName = conLBName.Text;
            MODEL.Desp = conLBMS.Text;

            foreach (RepeaterItem item in conRepSP.Items)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    if (item.FindControl("conSPID") != null)
                    {
                        TextBox txtPID = (TextBox)item.FindControl("conSPID");
                        HiddenField hidID = (HiddenField)item.FindControl("hidID");

                        int intPID = string.IsNullOrEmpty(txtPID.Text) ? 0 : int.Parse(txtPID.Text);
                        new PT_Index_TypeB().UpdateSPID(hidID.Value, intPID);
                    }
                }
            }

            return new PT_Index_TypeB().Update(MODEL);
        }
        #endregion

        #region//查看页面
        /// <summary>
        /// 初始化View页面
        /// </summary>
        /// <param name="intFormID">表单号</param>
        public override void initMangerForm(int intFormID)
        {
            PT_Index_Type MODEL = new PT_Index_Type();
            MODEL = new PT_Index_TypeB().GetEntity(d => d.ID == intFormID);
            conLBMS.Text = MODEL.Desp.ToString();
            conLBName.Text = MODEL.TypeName;
            conRepSP.DataSource = new PT_Index_TypeB().GetIndexList(MODEL.Type);
            conRepSP.DataBind();
        }

        #endregion





    }
}